<?php
		require('config.php');
		$user_id=$_REQUEST['user_id'];
        $goods_id=$_REQUEST['goods_id'];
        $goods_num=$_REQUEST['goods_num'];
        $shuxing_title=$_REQUEST['shuxing_title'];
        $shuxing_id=$_REQUEST['shuxing_id'];
		$sql="select * from `".$oto."_goods` where `goodsId`='".$goods_id."' LIMIT 1";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$goods[]=$row;//将取得的所有数据赋值给person_info数组
		}
		$sql="select * from `".$oto."_cart` where `userId`='$user_id' and `goods_id`='".$goods_id."' and `goods_attr`='$shuxing_title' LIMIT 1";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$car[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(!isset($car))
		{
			$shop_id=$goods[0]['shopId'];
			$goods_sn=$goods[0]['goodsSn'];
			$goods_name=$goods[0]['goodsName'];
			$market_price=$goods[0]['marketPrice'];
			$goods_price=$goods[0]['shopPrice'];
			$time=time();
			$sql="INSERT INTO ".$oto."_cart (`userId`,`goods_id`,`shop_id`,`goods_sn`,`goods_name`,`market_price`,`goods_price`,`goods_num`,`goods_attr`,`goodss_attr_id`,`add_time`) VALUES ('$user_id','$goods_id','$shop_id','$goods_sn','$goods_name','$market_price','$goods_price','$goods_num','$shuxing_title','$shuxing_id','$time')";
            $result=$db->query($sql);
		}
		else
		{
			$result=2;
		}
		echo json_encode($result);
?>